require('./Navbar.styl');
import classNames from 'classnames';
import Icon from 'salt-icon';
class Navbar extends React.Component {
    static defaultProps = {
        isShow: false
    };
    constructor(props) {
        super(props);
        this.state = {
            isShow: this.props.isShow,
        };
    }
    handleBackClick() {
        this.props.onLeftClick();
    }

    handleOptionClick() {
        this.props.onRightClick();
    }

    handleCloseView() {
        this.props.closeViewClick();
    }
    render() {
        const t = this;
        return (
            <div
                className={classNames('nav-bar', {
                    [t.props.className]: !!t.props.className,
                })}
            >
                <div className='nav-bar-left FAL'>
                    <div className={'nav-bar-left-option'} onClick={this.handleBackClick.bind(this)}>
                        <Icon className={'nav-bar-arrow-left'} name="angle-left" />
                        <span>返回</span>
                    </div>
                    {this.state.isShow ?
                        <span
                            className={'nav-bar-close'}
                            onClick={this.handleCloseView.bind(this)}
                        >关闭
                        </span>
                        : null
                    }
                </div>
                <div className='nav-bar-center nav-bar-center-text omit3 FAC'>
                    {this.props.title}
                </div>
                <div className='nav-bar-right FAR' onClick={this.handleOptionClick.bind(this)}>
                    <span className='nav-bar-right-text'>{this.props.rightText}</span>
                </div>
            </div>
        );
    }

    componentWillMount() {
    }

    componentDidMount() {
    }

    componentWillReceiveProps(nextProps) {
    }

    shouldComponentUpdate(nextProps, nextState) {
        return true;
    }

    componentWillUpdate(nextProps, nextState) {
    }

    componentDidUpdate(prevProps, prevState) {
    }

    componentWillUnmount() {
    }
}

module.exports = Navbar;
